package com.wyh.cloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author wyh
 * @version 1.0
 * @date 2021/11/18 14:52
 */
@Configuration
public class GateWayConfig {

    @Bean
    public RouteLocator customerRouteLocator(RouteLocatorBuilder routeLocatorBuilder){
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        routes.route("path_route_wyh",
                r -> r.path("/guonei")
                        .uri("https://news.baidu.com/guonei")).build();
        routes.route("path_route_wyh2",
                r -> r.path("/guoji")
                        .uri("https://news.baidu.com/guoji")).build();

        return routes.build();
    }
}
